package com.kaige.asktaoplugin60.exception;

import com.kaige.asktaoplugin60.common.Result;
import com.kaige.asktaoplugin60.enums.ResultCodeEnum;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

@Slf4j
@ControllerAdvice// 全局异常处理
public class GlobalExceptionHandler {
    @ResponseBody
    @ExceptionHandler(Exception.class)
    public Result<String> handleException(Exception e) {
        log.error("全局异常处理: {}", e.getMessage());
        return Result.error(ResultCodeEnum.UNKNOWN_ERROR);
    }
}
